<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>菜单管理--左边的树</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<!--<link rel="icon" href="/favicon.ico">-->
<link rel="stylesheet" href="/css/public.css" media="all" />
<div th:include="/common/layui"></div>
<div th:include="/common/dtree"></div>


</head>
<body shiro:hasPermission="menu:view">
<!-- 存放树的容器 -->
<ul id="menuTree" class="dtree" data-id="0"></ul>

<script type="text/javascript">
var menuTree;
layui.extend({
    dtree: '/layui_ext/dtree/dtree'   // {/}的意思即代表采用自有路径，即不跟随 base 路径
  }).use(['dtree','layer','jquery'], function(){
    var dtree = layui.dtree;
    var layer = layui.layer;
    $ = layui.jquery;

    // 初始化树
    menuTree= dtree.render({
      elem: "#menuTree",
      // async: true,
      dataStyle: "layuiStyle",  //使用layui风格的数据格式
      // dataFormat: "list",  //配置data的风格为list
      response:{message:"msg",statusCode:0},  //修改response中返回数据的定义
      url: "/admin/menu/loadMenuManagerLeftTreeJson" // 使用url加载（可与data加载同时存在）
    });

    // 绑定节点点击 触发加载右边菜单列表数据
    dtree.on("node(menuTree)" ,function(obj){
     // layer.msg(JSON.stringify(obj.param.nodeId));//{"nodeId":"undefined","parentId":"0","context":"湖南省","leaf":true,"level":"1","spread":false}
     console.log(JSON.stringify(obj.param));//{"nodeId":"undefined","parentId":"0","context":"湖南省","leaf":true,"level":"1","spread":false}
      window.parent.right.reloadTable(obj.param.nodeId);
    });
  });

</script>

</body>
</html>